Skip to content

[SYNCOPE-1981] Search audit events by who#1438

Open
ozimakov wants to merge 1 commit into
apache:masterfrom
ozimakov:SYNCOPE-1978
Open

[SYNCOPE-1981] Search audit events by who#1438
ozimakov wants to merge 1 commit into
apache:masterfrom
ozimakov:SYNCOPE-1978

Conversation

@ozimakov

@ozimakov ozimakov commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

SYNCOPE-1981

Split out from SYNCOPE-1978 per review: this PR adds searching by who performed the action. Matching audit events by the username of the affected entity (the actual subject of SYNCOPE-1978) will be addressed separately.

What

Adds the ability to search audit events by the principal that performed them. A new who query parameter on AuditQuery matches the AuditEvent.who column by exact value and may be repeated to match any of the given values (OR):

  • single — ?who=jsmith
  • multiple, OR-ed — ?who=jsmith&who=admin

It composes (AND) with the existing audit search filters (entityKey, type, category, op, outcome, before/after).

Why

There is no way to answer "what did administrator X do". This is useful to retrieve all actions performed by a given principal — in particular when that account has since been deleted and its entity key is no longer available. Syncope 3.0 allowed an approximation by abusing entityKey=<username>; the 4.0 audit refactor correctly made entityKey match only the affected entity's UUID, removing that side effect.

Implementation

The filter is threaded through AuditServiceImplAuditLogic → the AuditEventDAO interface and all of its implementations: JPA, Neo4j, Elasticsearch and OpenSearch.

  • JPA: who IN (?, ...) with bound parameters;
  • Neo4j: n.who IN $who with a bound list parameter;
  • Elasticsearch / OpenSearch: a term query per value, OR-ed via bool/should.

All values are bound as query parameters (SQL/Cypher) or passed as structured term queries (Elasticsearch/OpenSearch), so there is no injection surface.

Tests

New integration tests in AuditITCase cover exact match, multiple values (OR), no-match, and that the match is exact (a * is treated literally, not as a wildcard), composed with the other filters. Manually verified end-to-end against embedded PostgreSQL and Neo4j.

@ilgrosso ilgrosso left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is proposing to add the capability to search audit events by who, e.g. by the administrator that was logged as the requester for the action that was logged as audit entry.

I believe this is a nice addition but it will require a different issue on JIRA.

This because SYNCOPE-1978 is instead asking to restore the possibility to match audit events by username, e.g. to look for users whose payload was logged for the audit entry - as opposite as the current capability to look for such users only by their key.

@ozimakov ozimakov changed the title [SYNCOPE-1978] Search audit events by who (username) [SYNCOPE-1981] Search audit events by who Jun 25, 2026
@ozimakov

Copy link
Copy Markdown
Contributor Author

Hi @ilgrosso
Thank you so much for the eye-opening comment. It's always pretty refreshing to see that you've been following the false goal, haha.
I've created a new ticket and rerouted this PR against it. Also fixed the issues you've outlined. Hopefully, it still might be useful.
And I'll be working on the original issue (SYNCOPE-1978) in a separate PR.

Add the ability to search audit events by the principal that performed
them. A new "who" query parameter on AuditQuery matches the AuditEvent.who
column by exact value and may be repeated to match any of the given values
(OR), composing with the existing audit search filters.

The filter is threaded through AuditServiceImpl, AuditLogic and the
AuditEventDAO interface and all of its implementations (JPA, Neo4j,
Elasticsearch, OpenSearch). Values are bound as query parameters (SQL/Cypher)
or passed as structured term queries (Elasticsearch/OpenSearch), so there is
no injection surface. Covered by new integration tests in AuditITCase.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants